import java.util.Date;

/**
 * Created by thinkjoy on 2017/9/15.
 */
public class ConsumInfo implements  Comparable<ConsumInfo>{
    private long uid;
    private String ordered;
    private double price;
    private Date createTime;

    public ConsumInfo() {
    }

    public ConsumInfo(long uid, String ordered, double price, Date createTime) {
        this.uid = uid;
        this.ordered = ordered;
        this.price = price;
        this.createTime = createTime;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public String getOrdered() {
        return ordered;
    }

    public void setOrdered(String ordered) {
        this.ordered = ordered;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "ConsumInfo{" +
                "uid=" + uid +
                ", ordered='" + ordered + '\'' +
                ", price=" + price +
                ", createTime=" + createTime +
                '}';
    }

    /**
     * 倒序
     * @param o
     * @return
     */
    @Override
    public int compareTo(ConsumInfo o) {
        if (price<o.price){
            return 1;
        }
        if (price>o.price){
            return -1;
        }
        if (price==o.price){
            if(createTime.getTime()<o.createTime.getTime()){
                return 1;
            }
            if (createTime.getTime()>o.createTime.getTime()) {
                return -1;
            }
        }
        return 0;
    }
}
